package com.bawie.user.controller;

import com.bawie.entity.User;
import com.bawie.service.UserService;
import com.bawie.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.jws.soap.SOAPBinding;
import java.util.List;

@Controller
public class UserController {

    @Autowired
    private UserService userService;
   @RequestMapping("/list")
    public String getUser(ModelMap modelMap,String cpage) {
       int pageSize=3;
       int count=userService.getCount();

       PageUtil page=new PageUtil(cpage,count,pageSize,"");
       List<User> uses=userService.selectByCondition(new User(),page);
       modelMap.put("page",page);
       modelMap.put("users",uses);
       return "user";
    }

    @RequestMapping("/delAll")
    @ResponseBody
    public String delAll(Integer[] ids){
       userService.delAll(ids);
       return "ok";
    }
}
